using LoggingMagic.Injectors.Interfaces;
using LoggingMagic.Injectors.StaticField.Parameters;
using LoggingMagic.LoggingParameters;
using Mono.Cecil;

namespace LoggingMagic.Injectors.StaticField.Base
{
    internal class StaticFieldFactory : InjectorFactory
    {
        private readonly IStaticFieldParameters _parameters;

        public StaticFieldFactory(ModuleDefinition module, IAssemblyResolver resolver, IMethodFinderParameters methodFinderParameters, IStaticFieldParameters parameters)
            : base(module, resolver, methodFinderParameters)
        {
            _parameters = parameters;
        }

        private IInjector _withParameters;
        public override IInjector WithParameters
        {
            get
            {
                if (_withParameters == null)
                    _withParameters = new StaticFieldMethodCallWithParamsInjector(_module, _parameters, MethodParametersToArray);

                return _withParameters;
            }
        }

        private IInjector _wthoutParameters;
        public override IInjector WithoutParameters
        {
            get
            {
                if (_wthoutParameters == null)
                    _wthoutParameters = new StaticFieldMethodCallInjector(_module, _parameters);

                return _wthoutParameters;
            }
        }

    }
}